package com.foreveross.fetl.core.domain.task;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import com.dayatang.domain.InstanceFactory;
import com.foreveross.fetl.common.domain.BaseOracleEntity;
import com.foreveross.fetl.core.domain.task.repository.ExcelInfoRepository;

@javax.persistence.Entity
@Table(name = "FDC_EXCEL_INFO")
public class ExcelInfoEntity extends BaseOracleEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7532274320433582962L;
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	
	@Column(name = "NAME")
	private String name; //名称
	
	@Column(name = "UPLOAD_DATE")
	private Date uploadDate; //时间  
	
	@Column(name = "PATH")
	private String path;//路径
	
	@Column(name = "DATA_TYPE")
	private String dateType; // 生成日期str yyyyHHmmhh
	
	@Column(name = "COPE")
	private String code;//航空公司 code
	
	@Column(name="FILE_TYPE")
	private String fileType;
	
	@Column(name="TYPE")
	private Integer type;//1 单程 2 往返
	
	
	


	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public String getFileType() {
		return fileType;
	}

	public void setFileType(String fileType) {
		this.fileType = fileType;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Date getUploadDate() {
		return uploadDate;
	}

	public void setUploadDate(Date uploadDate) {
		this.uploadDate = uploadDate;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public String getDateType() {
		return dateType;
	}

	public void setDateType(String dateType) {
		this.dateType = dateType;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}
	
	
	
	public ExcelInfoRepository getExcelInfoRepository(){
		return InstanceFactory.getInstance(ExcelInfoRepository.class);
	}
	
	public List<ExcelInfoEntity> findAll(){
		return getExcelInfoRepository().findAll();
	}
	public void saveOrUpdate(ExcelInfoEntity excelInfo){
		getExcelInfoRepository().saveOrUpdate(excelInfo);
	}
	
	public void delete(ExcelInfoEntity excelInfo){
		getExcelInfoRepository().delete(excelInfo);
	}
	
	public ExcelInfoEntity findById(Long id){
		return getExcelInfoRepository().findById(id);
	}
	
	/**
	 * 查找日期格式 yyyyMMddHH < date的
	 * @param date
	 * @return
	 */
	public List<ExcelInfoEntity> findByTime(String date,String fileType,Integer type){
		return getExcelInfoRepository().findByTime(date,fileType,type);
	}
	
	/**
	 * 查找航空公司代码为code ,日期为date‘yyyyMMdd’的
	 * @param code
	 * @param date
	 * @return
	 */
	public List<ExcelInfoEntity> findBycode(String code ,String date,String fileType,Integer type){
		return getExcelInfoRepository().findBycode(code, date,fileType,type);
	}
	
	/**
	 * 查找航空公司代码为code,时间为 yyyyMMddHH 的
	 * @param code
	 * @param date
	 * @return
	 */
	public List<ExcelInfoEntity> findBycodeAndTime(String code ,String date,String fileType,Integer type){
		return getExcelInfoRepository().findBycodeAndTime(code, date,fileType,type);
	}
	
	/**
	 * 根据文件名查找
	 * @param name
	 * @return
	 */
	public ExcelInfoEntity findByName(String name,String fileType,Integer type){
		return getExcelInfoRepository().findByName(name,fileType,type);
	}
	

}
